local jjj__lianhuan = fk.CreateSkill {

  name = "jjj__lianhuan&",

  tags = {  },

}



jjj__lianhuan:addEffect("active", {
  name = "jjj__lianhuan&",
  card_num = 1,
  min_target_num = 0,
  can_use = function(self, player)
    return not player:isKongcheng() and player:usedSkillTimes(jjj__lianhuan.name, Player.HistoryTurn) < 3
  end,
  card_filter = function(self, to_select, selected, selected_targets)
    return #selected == 0 and Fk:getCardById(to_select).suit == Card.Club and Fk:currentRoom():getCardArea(to_select) ~= Player.Equip
  end,
  target_filter = function(self, player, to_select, selected)
    if #selected_cards == 1 then
      local card = Fk:cloneCard("iron_chain")
      card:addSubcard(selected_cards[1])
      return card.skill:canUse(player, card) and card.skill:targetFilter(to_select, selected, selected_cards, card) and
      not player:prohibitUse(card) and not player:isProhibited(Fk:currentRoom():getPlayerById(to_select), card)
    end
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    if #effect.tos == 0 then
      room:recastCard(effect.cards, player, jjj__lianhuan.name)
    else
      room:sortPlayersByAction(effect.tos)
      room:useVirtualCard("iron_chain", effect.cards, player, table.map(effect.tos, Util.Id2PlayerMapper), jjj__lianhuan.name)
    end
  end,
})

return jjj__lianhuan